package org.jeecg.jt808.req;

import io.netty.buffer.ByteBuf;
import lombok.Data;
import org.jeecg.jt808.vo.JT808DataPacket;


@Data
public class TransparencyMsg extends JT808DataPacket {

    // 透传消息类型
    private int transparentMsgType;
    // 透传消息内容长度
    private int transparentMsgContentLength;
    // 透传消息数据长度
    private int transparentMsgDataLength;
    // 透传消息内容
    private byte[] transparentMsgContent;

    public TransparencyMsg(ByteBuf byteBuf) {
        super(byteBuf);
    }

    @Override
    public void parseBody() {
        ByteBuf bb = this.payload;
        this.transparentMsgType = bb.readUnsignedByte();

        // 读取透传消息内容长度
        this.transparentMsgContentLength = bb.readInt();

        // 读取透传消息数据长度
        this.transparentMsgDataLength = bb.readUnsignedShort();

        // 根据长度读取透传消息内容
        this.transparentMsgContent = new byte[this.transparentMsgDataLength];
        System.out.println("透传数据内容"+this.transparentMsgContent.toString());
        bb.readBytes(this.transparentMsgContent);
    }
}